// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TraceSwitch.cs" company="AzureContrib (Open source library http://azurecontrib.codeplex.com)">
//   Microsoft Public License (Ms-PL)
// </copyright>
// <summary>
//   A trace switch similar to System.Diagnostics.TraceSwitch but focused on the Windows Azure scenario.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace AzureContrib.WindowsAzure.Diagnostics
{
	/// <summary>
	/// A trace switch similar to System.Diagnostics.TraceSwitch but focused on the Windows Azure scenario.
	/// </summary>
	public class TraceSwitch
	{
		/// <summary>
		/// Initializes a new instance of the <see cref='TraceSwitch'/> class.
		/// </summary>
		/// <param name="displayName">The human readable name of the switch.</param>
		/// <param name="description">Desciption of the switch.</param>
		/// <param name="level">The level to trace at.</param>
		public TraceSwitch(string displayName, string description, LogLevel level)
		{
			DisplayName = displayName;
			Description = description;
			Level = level;
		}

		/// <summary>
		/// Gets or sets the human readable name of the switch.
		/// </summary>
		public string DisplayName { get; set; }

		/// <summary>
		/// Gets or sets tesciption of the switch.
		/// </summary>
		public string Description { get; set; }

		/// <summary>
		/// Gets or sets the trace level that specifies what messages to output for tracing and debugging.
		/// </summary>
		public LogLevel Level
		{
			get; set; 
		}

		/// <summary>
		/// Gets a value indicating whether the <see cref='TraceSwitch.Level'/> is set to
		/// <see cref="LogLevel.Critical"/>, <see cref="LogLevel.Error"/>, <see cref="LogLevel.Warning"/>, <see cref="LogLevel.Information"/> or <see cref="LogLevel.Verbose"/>.
		/// </summary>
		public bool TraceCritical
		{
			get
			{
				return Level >= LogLevel.Critical;
			}
		}

		/// <summary>
		/// Gets a value indicating whether the <see cref='TraceSwitch.Level'/> is set to
		/// <see cref="LogLevel.Error"/>, <see cref="LogLevel.Warning"/>, <see cref="LogLevel.Information"/> or <see cref="LogLevel.Verbose"/>.
		/// </summary>
		public bool TraceError
		{
			get
			{
				return Level >= LogLevel.Error;
			}
		}

		/// <summary>
		/// Gets a value indicating whether the <see cref='TraceSwitch.Level'/> is set to
		/// <see cref="LogLevel.Warning"/>, <see cref="LogLevel.Information"/> or <see cref="LogLevel.Verbose"/>.
		/// </summary>
		public bool TraceWarning
		{
			get
			{
				return Level >= LogLevel.Warning;
			}
		}

		/// <summary>
		/// Gets a value indicating whether the <see cref='TraceSwitch.Level'/> is set to
		/// <see cref="LogLevel.Information"/> or <see cref="LogLevel.Verbose"/>.
		/// </summary>
		public bool TraceInformation
		{
			get
			{
				return Level >= LogLevel.Information;
			}
		}

		/// <summary>
		/// Gets a value indicating whether the <see cref='TraceSwitch.Level'/> is set to <see cref="LogLevel.Verbose"/>.
		/// </summary>
		public bool TraceVerbose
		{
			get
			{
				return Level == LogLevel.Verbose;
			}
		}
	}
}